from django.http import JsonResponse
from django.shortcuts import render
from rest_framework.decorators import api_view
from rest_framework.response import Response

from rest_framework import status
from rest_framework.views import APIView


# Create your views here.


@api_view(['GET'])
def get_data(request, format=None):
    print()
    return Response({'code': "成功"}, status=status.HTTP_201_CREATED)


@api_view(['POST', 'PUT', 'PATCH', 'DELETE'])
def add_data(request, format=None):
    print()
    return JsonResponse([1, 2, 3], {'code': "成功"}, safe=False)


class DemoView(APIView):
    def get(self, request):
        print(name)
        return Response({'code': 'get--ok'})

    def post(self, request):
        return Response({'code': 'post--ok'})

    def delete(self, request):
        return Response({'code': 'delete--ok'})

    def put(self, request):
        return Response({'code': 'put--ok'})
